import { adminUser } from "@/api/content.js";

export let adUser = {
    namespaced: true,
    state: () => ({ 
        users: []
     }),
    mutations: { 
        async getUsers(state){
            let data = await adminUser.getUsers();
            let user_role = ['管理员', 'SEO', '作者']
            data.forEach(item=>{
                item.role = user_role[item.role];
                item.showDialog = false;
            });
            state.users = data;
        },
        pushUser(state, user){
            state.users.push(user)
        },
        spliceUser(state, index){
            state.users.splice(index)
        }
    },
}